package com.quiputechnology.nexwm.web;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.quiputechnology.nexwm.service.UsuarioManager;

@Controller
public class HelloWorldController {
	private static final Logger logger = Logger
			.getLogger(HelloWorldController.class);

	@Autowired
	private UsuarioManager usuarioManager;

	@RequestMapping("/HelloWorld.htm")
	public ModelAndView helloWorld() {
		logger.debug("helloWorld");
		User u = (User) SecurityContextHolder.getContext().getAuthentication()
				.getPrincipal();

		return new ModelAndView("helloWorld", "usuario",
				usuarioManager.getUsuarioPorUsername(u.getUsername()));
	}

}